//
//  LYCashViewController.m
//  artist
//
//  Created by apple on 16/6/3.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYCashViewController.h"

@interface LYCashViewController ()
@property (weak, nonatomic) IBOutlet UIView *mainView;
@property (weak, nonatomic) IBOutlet UIButton *cashBtn;
@property (assign, nonatomic)  CGFloat money;
@property (weak, nonatomic) IBOutlet UITextField *textFeild;
@property (weak, nonatomic) IBOutlet UILabel *balanceLabel;

@property (weak, nonatomic) IBOutlet UIView *bankBackGroundView;
@end

@implementation LYCashViewController
- (instancetype)initWithMoney:(CGFloat)money{
    self = [self init];
    if(self){
        self.money = money;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.bankBackGroundView.hidden = YES;
    _mainView.layer.cornerRadius = 10;
    _mainView.layer.masksToBounds = YES;
    
    _cashBtn.layer.cornerRadius = 10;
    _cashBtn.layer.masksToBounds = YES;
    
    self.balanceLabel.text = [NSString stringWithFormat:@"余额¥%0.1f", self.money];
    
    

}
- (IBAction)cashButtonDidPress:(UIButton *)sender {
    
    
//    [self.textFeild.text ]
    
    if ([self.textFeild.text integerValue] > 0 || self.textFeild.text.length == 0){
        
        [SVProgressHUD showErrorWithStatus:@"请输入正确金额"];
    }
    
    [SVProgressHUD showWithStatus:@"提交申请"];
    WS(weakSelf)
    [LYRequestTool applyChangeCashWithToken:[AppDelegate shareInstance].token money:self.textFeild.text  success:^{
        [SVProgressHUD showSuccessWithStatus:@"提交成功"];
        [weakSelf.navigationController popViewControllerAnimated:YES];

    } failure:^(NSString *code, NSString *message) {
        [SVProgressHUD showErrorWithStatus:message];
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
